import { Component, Input } from '@angular/core';
import { DirctoryService } from 'src/app/@core/services/dirctory/dirctory.service';
@Component({
  selector: 'app-paused',
  templateUrl: './paused.component.html',
  styleUrls: ['./paused.component.scss']
})
export class PausedComponent {
  @Input() data:any
  pauseInfo = {
    JobOrderId: '', // 工单id
    processId: '', // 工序id
    processNumber: 0, // 工序序号
    pauseTime: null, // 暂停时间
    pauseReason: '', // 暂停原因
    name: '', // 暂停人
    employeeCode:0
  };
  timerId: any;
  pauseReasons: any=[];
  constructor(private DirctoryService:DirctoryService){
    const userinfo = localStorage.getItem('userinfo');
    if (userinfo) {
      const parsedUserinfo = JSON.parse(userinfo);
      this.pauseInfo.name = parsedUserinfo.username;
      this.pauseInfo.employeeCode = parsedUserinfo.employeeCode;
    }
  }
  ngOnInit(): void {
    this.pauseInfo.JobOrderId = this.data.jobOrderId;
    this.pauseInfo.processId = this.data.processId;
    this.pauseInfo.processNumber = this.data.processNumber;
    this.timerId = setInterval(() => {
      this.pauseInfo.pauseTime = new Date();
    }, 1000);
    this.DirctoryService.getDictionaryEntriesByCategoryName("暂停原因").subscribe((res:any)=>{
      this.pauseReasons = res.value
    })
  }
  ngOnDestroy(): void {
    if (this.timerId) {
      clearInterval(this.timerId);
    }
  }
}
